import os
import subprocess


class Compressor:

    def __init__(self, filename):
        self.filename = filename

    def compress(self):

        compressed = self.filename + '.bz2'
        if os.path.exists(compressed):
            os.remove(compressed)

        subprocess.run(['bzip2', '-k', self.filename])

        if os.path.exists(self.filename):
            print('File retained')
        else:
            print('File deleted')
